/*
 * Application.cpp
 *
 *  Created on: 2013.01.10.
 *      Author: Thg
 */

#include "Trace.h"

#include "Application.h"

#include <GL/glew.h>
#include <GL/glfw.h>
#include <GL/freeglut.h>

#include <stdio.h>
#include <string.h>

Application* Application::mApp = 0;

Application::Application(const char* windTitle, long width, long height)
{
	traceMethod();
    mApp              = this;
    mApplicationType  = UnknownApplication;
    mWindowWidth      = width;
    mWindowHeight     = height;
    strcpy(mWindowTitle, windTitle);
    mMousePressed     = false;
    mMouseSensitivity = 1;
    mMousePosX        = 0;
    mMousePosY        = 0;
    mTime             = 0;
}

Vector&
Application::eye()
{
	traceMethod();
	return position;
}

bool Application::getKeyStatus(int keyCode) const
{
	traceMethod();
    if (mApplicationType == GlfwApplication)
    {
    	if (keyCode == KeyUp)
    		return glfwGetKey(GLFW_KEY_UP) || glfwGetKey((char)'W');

    	if (keyCode == KeyLeft)
    		return glfwGetKey(GLFW_KEY_LEFT) || glfwGetKey((char)'A');

    	if (keyCode == KeyDown)
    		return glfwGetKey(GLFW_KEY_DOWN) || glfwGetKey((char)'S');

    	if (keyCode == KeyRight)
    	    return glfwGetKey(GLFW_KEY_RIGHT) || glfwGetKey((char)'D');

    	if (keyCode == KeyLeft)
    	    return glfwGetKey(GLFW_KEY_UP) || glfwGetKey((char)'W');
    }

    return false;
}

void Application::swapBuffers() // buffercsere
{
	traceMethod();
    //if (mApplicationType == GlfwApplication) glfwSwapBuffers();
}

